home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6239 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: darkstar.UCSC.EDU!kama!jono
  2. From: jono@cse.ucsc.edu (Jonathan Gibbs)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: newing char**
  5. Date: 12 Feb 1996 04:43:49 GMT
  6. Organization: UC Santa Cruz CIS/CE
  7. Message-ID: <4fmgi5$jvv@darkstar.UCSC.EDU>
  8. References: <4fggal$4pf@darkstar.UCSC.EDU>
  9. NNTP-Posting-Host: kama.cse.ucsc.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Thanks for the replies. Unfortunatly I made a few typos in the post.
  13. The solution was change
  14.    name = new (char*)[num];
  15. to
  16.    name = new char*[num];
  17.  
  18. Does anyone know if the () are legal, though?
  19.  
  20. Jonathan Gibbs (jono@cse.ucsc.edu) wrote:
  21. : If I have the following declaration:
  22.  
  23. : char **name;
  24.  
  25. : The following line compiles fine with g++, but I get the following 
  26. : error on SGI's CC. Which is right?
  27.  
  28. : int num; 
  29.  
  30. of course, I set num in here.
  31.  
  32. : name = new (char*)[num];
  33. : for (int i=0; i < num; i++) {
  34. :    name = new char[25];
  35.  
  36. oops, forgot to type the [i] after name.
  37.  
  38. : }
  39.  
  40. : SGI Error:
  41. : "segment.c++", line 43: error(3611): a value of type "char *" cannot be
  42. :       assigned to an entity of type "char **"
  43. :        _child_name = new (char*)[_num_children];
  44.  
  45.  
  46.  
  47.  
  48. : --
  49. : "The human mind is a dangerous plaything, boys. When it's used for evil, 
  50. : watch out! But when it's used for good, then things are much nicer." 
  51. :                                                             -- The Tick
  52. : <Home Page: http://www.cse.ucsc.edu/~jono>
  53.  
  54. --
  55. "The human mind is a dangerous plaything, boys. When it's used for evil, 
  56. watch out! But when it's used for good, then things are much nicer." 
  57.                                                             -- The Tick
  58. <Home Page: http://www.cse.ucsc.edu/~jono>
  59.